package com.marshall.scstudy.common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * Created by
 * autor : Marshall lky
 * datetime: 2021/11/1 15:53
 */
public class TestTemp
{


    private static Boolean getMonthYY(String establishmentDate, int count, Boolean flag) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendarEsd = Calendar.getInstance();
        try {
            calendarEsd.setTime(sdf.parse(establishmentDate));
            calendarEsd.add(Calendar.MONTH, count);
            System.out.println("半年后:" + sdf.format(calendarEsd.getTime()));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Calendar today = Calendar.getInstance();
        if (!flag) {
            return calendarEsd.after(today);
        } else {
            return calendarEsd.before(today);
        }
    }

    public static void main(String[] args) {

        String establishmentDate ="2014-10-21";
        if (getMonthYY(establishmentDate, 12, true)) {
            System.out.println("aaaa");
        }
    }
}
